﻿using System.Collections.Generic;



namespace Crocodile.SimplexLanguage.Tree
{
    /// <summary>
    /// SimplexEntity is a common element of the Simplex Language --
    /// a line with sublines.
    /// </summary>
    /// <stereotype>entity</stereotype>
    public class SimplexEntity : SimplexBlock
    {
        /// <summary>
        /// Name of the file this entity from.
        /// </summary>
        public string FileName;

        /// <summary>
        /// Number of line in the containing file.
        /// Starts with 1.
        /// </summary>
        public int LineNr;

        /// <summary>
        /// Offset of the first character in the line,
        /// or count of spaces before the first non-space character.
        /// </summary>
        public int Offset;

        /// <summary>
        /// The line;
        /// without heading spaces.
        /// </summary>
        public string Line;

        /// <summary>
        /// Nested lines.
        /// May be null.
        /// </summary>
        public readonly IList<SimplexEntity> Content = new List<SimplexEntity>(1);


        int SimplexBlock.Offset
        {
            get { return Offset; }
        }


        IList<SimplexEntity> SimplexBlock.Content
        {
            get { return Content; }
        }


        /// <summary>
        /// Checks whether the entity has at least one sub line.
        /// </summary>
        public bool HasContent { get { return Content.Count > 0; } }

    }
}
